package org.phalanx.client.dialogs;

import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class PhalanxOnlineStatusPanel extends JPanel {
	private PhalanxWindow masterFrame;
	private JLabel pStatus;
	public static final String NAME = "STATUSPANEL";
	
	public PhalanxOnlineStatusPanel(PhalanxWindow masterFrame){
		this.masterFrame = masterFrame;
		initializePanel();
	}
	
	private void initializePanel(){
		this.setForeground(Color.white);
		this.setBackground(Color.black);
		this.setLayout(new FlowLayout(FlowLayout.CENTER));
		pStatus = new JLabel();
		setStatus(false);
		this.add(pStatus);
	}
	
	public void setStatus(boolean isOnline){
		Color statusColor = isOnline ? Color.green : Color.red;
		String statusText = isOnline ? "Status: Connected" : "Status: Offline";
		
		pStatus.setForeground(statusColor);
		pStatus.setText(statusText);
	}
	
	public void setStatusText(String textMessage, Color c){
		Color statusColor = c;
		
		pStatus.setForeground(c);
		pStatus.setText(textMessage);
	}
	
	public PhalanxWindow getMasterFrame(){
		return this.masterFrame;
	}
}
